<?php 
/**
 * 厂家应付款统计
 * @copyright   Copyright (c) 2006 - 2010 DZH 友拓软件友拓通
 * @category   	账目信息
 * @package  	Action
 * @author    	李恺弘
 * @version 	2.1,2012-07-22
 */

class FactoryStatPublicAction extends CommonAction {
	
	 function _initialize(){
	 	addLang('stat');
	 	parent::_initialize();
	 } 
	 
	   ///查看列表
	   public function index() { 
	   		$this->statFundDate();	///统计日期的显示公式	
	       ///获取当前Action名称
		 	$name = $this->getActionName(); 
	 		///获取当前模型
			$model 	= D($name);      
			///格式化+获取列表信息  
			$list	=	$model->getIndex(); 
			///assign
			$this->assign('list',$list);
			$this->assign('company_currency_count',C('factory_currency_count'));
			///display
			$this->displayIndex(); 
    	}
    	
    	///查看明细
    	public function view() {  
	       ///获取当前Action名称
		 	$name = $this->getActionName(); 
	 		///获取当前模型
			$model 	= D($name);     
			///格式化+获取列表信息  
			$list	=	$model->getDetail(); 
			///assign
			$this->assign('list',$list);
			$this->assign('link1',U('/FactoryStat/view/type/1/currency_id/'.$_GET['currency_id'].'/comp_id/'.$_GET['comp_id'].''));
			$this->assign('link2',U('/FactoryStat/view/type/2/currency_id/'.$_GET['currency_id'].'/comp_id/'.$_GET['comp_id'].''));
			$this->assign('link3',U('/FactoryStat/view/type/3/currency_id/'.$_GET['currency_id'].'/comp_id/'.$_GET['comp_id'].''));   
			$dd_factory = S('factory');
			$this->factory_name = $dd_factory[$_GET['comp_id']]['factory_name'];
			$this->display('view');
    	}
    	
    	
    	///统计日期的显示公式
		public function statFundDate(){ 
			if ($_POST['date']['from_paid_date']){ 
				if (empty($_POST['date']['to_paid_date'])){
					$_POST['date']['to_paid_date']	=	date('Y-m-d');	
				} 
				$_POST['paid_date']				=	$_POST['date']['to_paid_date'];
			}elseif ($_POST['date']['to_paid_date'] && empty($_POST['date']['from_paid_date'])){
				$_POST['paid_date']	=	$_POST['date']['lt_paid_date']	=	$_POST['date']['to_paid_date'];
				unset($_POST['date']['to_paid_date']);
			}
		}
}